<template>
	<view>
		<view class="main">
			<view class="avatar">
				<u-avatar :src="src" size="160"></u-avatar>
				<text>账户：{{user.userName}}</text>
			</view>
			<view class="set">
				<navigator url="/pages/userinfo/userinfo" class="set-item">
					<text>个人信息</text>
					<u-icon name="arrow-right"></u-icon>
				</navigator>
				<navigator url="/pages/password/password" class="set-item">
					<text>修改密码</text>
					<u-icon name="arrow-right"></u-icon>
				</navigator>
				<navigator url="/pages/order/order" class="set-item">
					<text>订单列表</text>
					<u-icon name="arrow-right"></u-icon>
				</navigator>
				<navigator url="/pages/feedback/feedback" class="set-item">
					<text>意见反馈</text>
					<u-icon name="arrow-right"></u-icon>
				</navigator>
			</view>
		</view>
		<button class="bu" @click="show = true" style="width: 100%;height: 100rpx;
		background-color: #fa3534;font-size: 36rpx;margin-top: 40rpx;">退出登录</button>
		<u-modal v-model="show" :content="content" :title="title" show-cancel-button @confirm="confirm"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: () => {},
				src: '',
				show: false,
				title: '温馨提示',
				content: '确定要退出吗'
			};
		},
		onLoad() {
			this.getUser()
		},
		methods: {
			getUser(){
				this.$request({
					url: '/prod-api/api/common/user/getInfo'
				}).then(res => {
					this.user = res.user
				})
			},
			confirm(){
				uni.showToast({
					title:'退出成功'
				})
				uni.removeStorageSync('token')
				setTimeout(() => {
					uni.reLaunch({
						url:'/pages/login/login'
					})
				}, 1000)
			}
		}
	}
</script>

<style lang="scss">
page{
	background-color: #f7f7f7;
	view{
		padding: 20rpx;
		.main{
			padding: 20rpx;
			background-color: #fff;
			.avatar{
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
			}
			.set{
				padding: 20rpx;
				display: flex;
				flex-direction: column;
				.set-item{
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					align-items: center;
					padding: 20rpx;
					font-size: 32rpx;
				}
			}
		}
	}
}
</style>